package org.example.transaction_springboot_demo.controller;

import org.example.transaction_springboot_demo.mapper.d1.D1User;
import org.example.transaction_springboot_demo.mapper.d2.D2User;
import org.example.transaction_springboot_demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/tran")
@RestController
public class TransController {

    @Autowired
    D1User d1User;

    @Autowired
    D2User d2User;

    @Autowired
    UserService userService;

    @GetMapping("/test")
    public String test() {
        d1User.updateUser(110, 1);
        d2User.updateUser(190, 1);
        return "ok";
    }

    @GetMapping("/testSeata")
    public String testSeata() {
        userService.transfer();
        return "ok";
    }
}
